home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / EX8_6.C < prev    next >
C/C++ Source or Header  |  1992-08-20  |  1KB  |  33 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12.  
  13. #include <cool/Bit_Set.h>            // COOL Bit Set class
  14.  
  15. enum colors { RED=1, YELLOW, PINK, GREEN, ORANGE, PURPLE, BLUE };
  16.  
  17. static colors color_table[] = {RED, YELLOW, PINK, GREEN, ORANGE, PURPLE, BLUE};
  18.  
  19. int main (void) {
  20.   CoolBit_Set a, b;                // Declare two bit set objects
  21.   for (int i = 0; i < 5; i++) {            // For each color defined
  22.     a.put (color_table[i]);            // Add object to first set
  23.     b.put (color_table[6-i]);            // Add end object to second set
  24.   }
  25.   cout << "Set A contains: " << a;         // Elements of set 1
  26.   cout << "Set B contains: " << b;         // Elements of set 2
  27.   cout << "A | B: " << (a | b);            // Display union
  28.   cout << "A & B: " << (a & b);            // Display intersection
  29.   cout << "A ^ B: " << (a ^ b);            // Display XOR
  30.   cout << "A - B: " << (a - b);            // Display difference
  31.   return (0);                    // Exit with OK status
  32. }
  33.